{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import tushare as ts\n",
    "import MySQLdb as mdb\n",
    "\n",
    "import matplotlib\n",
    "matplotlib.use(\"TkAgg\")\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "from matplotlib.collections import LineCollection\n",
    "\n",
    "import pandas as pd\n",
    "from sklearn import cluster,covariance,manifold\n",
    "\n",
    "from matplotlib.font_manager import FontProperties\n",
    "\n",
    "\n",
    "import tushare as ts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "pro = ts.pro_api('d3890d410094f6cf665e6bb0652f8848aefddb9d7002c54e74ebfb0c')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 5392 entries, 0 to 5391\n",
      "Data columns (total 10 columns):\n",
      " #   Column        Non-Null Count  Dtype \n",
      "---  ------        --------------  ----- \n",
      " 0   ts_code       5392 non-null   object\n",
      " 1   symbol        5392 non-null   object\n",
      " 2   name          5392 non-null   object\n",
      " 3   area          5377 non-null   object\n",
      " 4   industry      5377 non-null   object\n",
      " 5   cnspell       5392 non-null   object\n",
      " 6   market        5392 non-null   object\n",
      " 7   list_date     5392 non-null   object\n",
      " 8   act_name      2544 non-null   object\n",
      " 9   act_ent_type  2544 non-null   object\n",
      "dtypes: object(10)\n",
      "memory usage: 421.4+ KB\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "ts_code         5392\n",
       "symbol          5392\n",
       "name            5392\n",
       "area            5377\n",
       "industry        5377\n",
       "cnspell         5392\n",
       "market          5392\n",
       "list_date       5392\n",
       "act_name        2544\n",
       "act_ent_type    2544\n",
       "dtype: int64"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pro.query('stock_basic', exchange='',list_status='L')\n",
    "data.info()\n",
    "data.count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5392"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sqlalchemy import create_engine\n",
    "\n",
    "engine = create_engine('mysql+pymysql://root:Sdz041119@localhost/stock_basic')\n",
    "\n",
    "data.to_sql('stock_basic', con=engine, if_exists='replace', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 000001.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000001.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2 000002.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000002.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3 000004.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000004.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 000006.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000006.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5 000007.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000007.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6 000008.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000008.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7 000009.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000009.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8 000010.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000010.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "9 000011.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000011.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10 000012.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000012.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11 000014.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000014.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12 000016.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000016.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "13 000017.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000017.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14 000019.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000019.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "15 000020.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000020.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16 000021.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000021.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "17 000025.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000025.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "18 000026.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000026.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "19 000027.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000027.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20 000028.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000028.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "21 000029.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000029.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "22 000030.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000030.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "23 000031.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000031.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24 000032.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000032.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "25 000034.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000034.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "26 000035.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000035.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "27 000036.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000036.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "28 000037.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000037.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "29 000039.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000039.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "30 000040.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000040.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "31 000042.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000042.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "32 000045.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000045.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "33 000048.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000048.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34 000049.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000049.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "35 000050.SZ\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\29389\\AppData\\Local\\Temp\\ipykernel_34424\\488590468.py:12: UserWarning: The provided table name '000050.SZ' is not found exactly as such in the database after writing the table, possibly due to case sensitivity issues. Consider using lower case table names.\n",
      "  data_price.to_sql(stock, con=engine, if_exists='append', index=False)\n"
     ]
    }
   ],
   "source": [
    "stock_list = data['ts_code'].tolist()\n",
    "\n",
    "data_price=[]\n",
    "\n",
    "i=0\n",
    "for stock in data['ts_code'].tolist():\n",
    "            if i==35:\n",
    "                    break\n",
    "            i+=1\n",
    "            print(i,stock)\n",
    "            data_price=pro.daily(ts_code=stock)\n",
    "            data_price.to_sql(stock, con=engine, if_exists='append', index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   count(*)\n",
      "0      5392\n",
      "     ts_code  symbol  name area industry cnspell market list_date act_name  \\\n",
      "0  688698.SH  688698  伟创电气   江苏     电气设备    wcdq    科创板  20201229     None   \n",
      "\n",
      "  act_ent_type  \n",
      "0         None  \n"
     ]
    }
   ],
   "source": [
    "sql = \"select count(*) from stock_basic.stock_basic\"\n",
    "df = pd.read_sql(sql, engine)\n",
    "print(df)\n",
    "\n",
    "sql = \"select * from stock_basic.stock_basic where name='伟创电气'\"\n",
    "df = pd.read_sql(sql, engine)\n",
    "print(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "        ts_code trade_date  open  high   low  close  pre_close  change  \\\n",
      "0     000035.SZ   20250122  4.61  4.63  4.44   4.48       4.64   -0.16   \n",
      "1     000035.SZ   20250121  4.70  4.71  4.62   4.64       4.67   -0.03   \n",
      "2     000035.SZ   20250120  4.67  4.72  4.63   4.67       4.65    0.02   \n",
      "3     000035.SZ   20250117  4.66  4.68  4.61   4.65       4.67   -0.02   \n",
      "4     000035.SZ   20250116  4.56  4.69  4.55   4.67       4.56    0.11   \n",
      "...         ...        ...   ...   ...   ...    ...        ...     ...   \n",
      "5995  000035.SZ   19950919  4.16  4.22  4.10   4.12       4.20   -0.08   \n",
      "5996  000035.SZ   19950918  4.23  4.25  4.15   4.20       4.20    0.00   \n",
      "5997  000035.SZ   19950915  4.22  4.29  4.16   4.20       4.22   -0.02   \n",
      "5998  000035.SZ   19950914  4.25  4.25  4.19   4.22       4.20    0.02   \n",
      "5999  000035.SZ   19950913  4.24  4.24  4.16   4.20       4.21   -0.01   \n",
      "\n",
      "      pct_chg        vol      amount  \n",
      "0     -3.4483  294776.94  132686.777  \n",
      "1     -0.6424  107610.50   50079.194  \n",
      "2      0.4301  146231.73   68333.322  \n",
      "3     -0.4283  121189.01   56326.197  \n",
      "4      2.4123  255410.31  118795.871  \n",
      "...       ...        ...         ...  \n",
      "5995  -1.9000     899.00     373.880  \n",
      "5996   0.0000    1123.00     469.604  \n",
      "5997  -0.4700    1134.00     475.150  \n",
      "5998   0.4800    1884.00     793.873  \n",
      "5999  -0.2400    1010.00     422.305  \n",
      "\n",
      "[6000 rows x 11 columns]\n"
     ]
    }
   ],
   "source": [
    "sql = \"select * from stock_basic.`000035.sz`\"\n",
    "df = pd.read_sql(sql, engine)\n",
    "print(df)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
